package com.lz.sports.widget

import android.os.SystemClock
import android.view.View

//防抖动点击回调
abstract class ShakeClickListener(private val shakeDiffTime: Long = 1000L) : View.OnClickListener {

    private var lastTime = SystemClock.elapsedRealtime()

    override fun onClick(v: View) {
        var currentTime = SystemClock.elapsedRealtime()
        if (currentTime - lastTime < shakeDiffTime) {
            return
        }
        lastTime = currentTime
        shakeClick(v)
    }

    abstract fun shakeClick(v: View)
}